package com.hyh.shiyanshiguanli.mapper;

import com.github.pagehelper.Page;
import com.hyh.shiyanshiguanli.domain.dto.ClassifyUpdateDTO;
import com.hyh.shiyanshiguanli.domain.dto.LibInformationUpdateDTO;
import com.hyh.shiyanshiguanli.domain.dto.LibUpdateByClassifyDTO;
import com.hyh.shiyanshiguanli.domain.dto.PageDTO;
import com.hyh.shiyanshiguanli.domain.entity.LibInformation;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @author hyh
 * @version 1.0
 */
@Mapper
public interface LibInformationMapper {

    /**
     * 分页查询
     * @param pageDTO
     * @return
     */

    Page<LibInformation> page(PageDTO pageDTO);

    @Select("select * from lib where id = #{id}")
    LibInformation selectById(Integer id);

    void updateById(LibInformation libInformation);

    @Insert("insert into lib (number, description, open, close, lib_classify_id, lib_classify, lib_manager, lib_manager_id) " +
            "values (#{number},#{description},#{open},#{close},#{libClassifyId},#{libClassify},#{libManager},#{libManagerId})")
    void add(LibInformation libInformation);

    @Delete("delete from lib where id = #{id}")
    void deleteById(@Param("id") Integer id);


    void updateByLibManagerId(LibUpdateByClassifyDTO libUpdateByClassifyDTO);

    @Select("select * from  lib where lib_classify_id = #{id} and status = 0")
    List<LibInformation> LabSelectById(@Param("id") Integer id);

    @Update("update lib set status = 1 where id = #{labId} ")
    void setStatusById(@Param("labId") Integer labId);

    @Update("update lib set status = 0 where id = #{labId} ")
    void setOStatus(@Param("labId") Integer labId);
}
